package markdown;

import entity.MarkDownData;
import freemarker.template.Template;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Writer;

public abstract class AbstractFreeMarkerProcessor implements Processor {
  
      protected abstract Template getTemplate() throws IOException, Exception;
  
      protected abstract Object getModel(MarkDownData sourceNoteData);
  
      protected abstract Writer getWriter(MarkDownData sourceNoteData) throws FileNotFoundException, Exception;
  
  
      @Override
      public final void process(MarkDownData sourceNoteData) throws Exception {
          Template template = getTemplate();
          Object model = getModel(sourceNoteData);
          Writer writer = getWriter(sourceNoteData);
          template.process(model, writer);
      }
  }
